import request from "@/router/axios";

export const getList = (page, size, params) => {
  return request({
    url: "/base/sellerGoods/IntegralList",
    method: "post",
    params: {
      ...params,
      page,
      size
    }
  });
};

export const remove = id => {
  return request({
    url: "/base/sellerGoods/delete",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: {
      id
    }
  });
};

export const add = row => {
  return request({
    url: "/base/sellerGoods/addItem",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: row
  });
};

//商品上架架
export const upperOrlower = (goodsId,operation) => {
  return request({
    url: "/base/sellerGoods/upperOrLowerIntegralGoods",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: {
        goodsId,
        operation
    }
  });
};

export const showGoodsStock = (goodsId) => {
  return request({
    url: "/base/sellerIntegralGoods/showGoodsStock",
    method: "post",
    meta: {
      isSerialize: true
    },
    data:{
      goodsId
    }
  });
};

export const changeStatus = (userId, status) => {
  return request({
    url: "/base/sellerGoods/changeStatus",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: {
      userId,
      status
    }
  });
};
// 查看拒绝原因
export const checkReasons = (id) => {
    return request({
        url: "/base/sellerGoods/checkReasons",
        method: "post",
        params: {
            id
        }
    });
};
// 商品上下架功能
export const upperOrLower = (id, operation) => {
  return request({
    url: "/base/sellerGoods/upperOrLowerGoods",
    method: "post",
    data: {
      id,
      operation
    }
  });
};
export const updateDisplay = (id, storeRecommend) => {
  // 这里classDisplay如果是boolean类型,无法传入后台,待以后优化吧
  return request({
    url: "/base/sellerGoods/editItem",
    method: "post",
    meta: {
      isSerialize: true
    },
    data: {
      id,
        storeRecommend,
    }
  });
};

export const getGoodsClassAll = () => {
  return request({
    url: "/base/sellerGoodsClass/classData",
    method: "post"
  });
};

export const editGoodsStock = (data) => {
  return request({
    url: "/base/sellerIntegralGoods/editGoodsStock",
    method: "post",
    meta: {
      isSerialize: true
    },
    data:data
  });
};
